/**
 * 比赛步骤模型
 *
 * 任务一
 * 根据比赛查出比赛步骤
 *
 */

module.exports = class extends think.Model
{

    get relation()
    {
        return {
            stepsaward:{
                type:think.Model.HAS_MANY,
                key:'PK_CompetitionStepsGuid',
                fKey:'FK_CompetitionStepsGuid'
            },competitionstepstojudger:{
                type:think.Model.HAS_MANY,
                key:'PK_CompetitionStepsGuid',
                fKey:'FK_CompetitionStepsGuid'
            }
        }
    }

    get pk(){
        return 'PK_CompetitionStepsGuid';
    }

    /**
     * 根据比赛查出比赛步骤
     * @param PK_CompetitionGuid
     * @param field
     * @returns {Promise.<*>}
     */
    async getCPStepsByCPGuid(PK_CompetitionGuid,field='PK_CompetitionStepsGuid'){
        let where={'FK_CompetitionGuid':PK_CompetitionGuid}
        return await this.where(where).field(field).select();
    }
}